SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.paDepurarCapacitaciones 

@Capacitacion INT,
@CapacitacionDesnormalizada INT

AS
SET NOCOUNT ON
BEGIN TRANSACTION

UPDATE tb_CapacitacionesDelAgente SET Capacitacion = @Capacitacion WHERE Capacitacion = @CapacitacionDesnormalizada
DELETE tb_Capacitaciones WHERE IdCapacitacion = @CapacitacionDesnormalizada

IF @@error <> 0
	ROLLBACK TRANSACTION
ELSE
	COMMIT TRANSACTION
GO
GRANT EXECUTE ON  [dbo].[paDepurarCapacitaciones] TO [Juntas]
GO
